import time
from common.unit import AndroidUI


class FirstUseObject:

    def __init__(self):
        self.driver = AndroidUI.get_webdriver()

    # 返回按钮
    def back_button(self):
        element = self.driver(resourceId="com.bluephone:id/iv_back")
        return element

    # 医院输入框
    def enter_button(self):
        element = self.driver(resourceId="com.bluephone:id/other_et")
        return element

    def choise(self, name):
        # element = self.driver.xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[4]/android.widget.TextView")
        element = self.driver(text=f'{name}')
        # element = self.driver.xpath("//android.widget.TextView[@text='展厅医院'")
        # element=self.driver.find_element_by_android_uiautomator('new UiSelector().text("展厅医院")')
        return element

    # 搜索按钮
    def search_button(self):
        element = self.driver(resourceId="com.bluephone:id/other_ok")
        return element

    # 选择展厅医院
    def select_hospital(self):
        element = self.driver.xpath("//android.widget.TextView[@text='展厅医院']")
        return element

    # 首次使用按钮
    def first_use_button(self):
        element = self.driver(resourceId="com.bluephone:id/systemSet1")
        return element
